package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class GoodAndEvil extends CustomRelic {

    public static final String ID = GunfireMod.makeID("GoodAndEvil");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("GoodAndEvil.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public GoodAndEvil() {
        super(ID, IMG, OUTLINE, RelicTier.COMMON, LandingSound.CLINK);
    }

    @Override
    public void onPlayerEndTurn() {
        for(AbstractMonster m : AbstractDungeon.getCurrRoom().monsters.monsters){
            if(!m.isDeadOrEscaped()){
                if(GunfireMod.isIntentAttack(m.intent)){
                    this.flash();
                    this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
                    this.addToBot(new GainBlockAction(AbstractDungeon.player, AbstractDungeon.player, 3));
                }
                if(GunfireMod.isIntentDefend(m.intent)){
                    this.flash();
                    this.addToBot(new RelicAboveCreatureAction(m, this));
                    this.addToBot(new DamageAction(m, new DamageInfo(null, 3, DamageInfo.DamageType.THORNS), AbstractGameAction.AttackEffect.BLUNT_LIGHT));
                }
            }
        }
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new GoodAndEvil();
    }
}
